/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JDialogSynchronization.java
 *
 * Created on 16/06/2011, 13:57:35
 */
package systole.synchronization.view;

import org.jdesktop.application.Action;
import org.jdesktop.swingx.JXBusyLabel;
import systole.synchronization.SyncController;
import systole.utils.ImageUtils;

/**
 *
 * @author Juan Manuel
 */
public class JDialogSynchronization extends javax.swing.JDialog {

    private SyncController controller;
    
    /** Creates new form JDialogSynchronization 
     * @param  parent
     *@param controller
     */
    public JDialogSynchronization(java.awt.Frame parent, SyncController controller) {
        super(parent, true);
        initComponents();
        this.controller = controller;
        this.setIconImage(ImageUtils.buildImage("resources/icons/sync/sync_16.png"));
        this.jXImagePanel1.setImage(ImageUtils.buildImage("resources/icons/sync/sync.png"));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPnlMain = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jProgressBar1 = new javax.swing.JProgressBar();
        jXImagePanel1 = new org.jdesktop.swingx.JXImagePanel();
        jXBusyLabel = new org.jdesktop.swingx.JXBusyLabel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getResourceMap(JDialogSynchronization.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setModal(true);
        setName("Form"); // NOI18N
        setResizable(false);

        jPnlMain.setName("jPnlMain"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getActionMap(JDialogSynchronization.class, this);
        jButton1.setAction(actionMap.get("cancel")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        jProgressBar1.setName("jProgressBar1"); // NOI18N
        jProgressBar1.setStringPainted(true);

        jXImagePanel1.setName("jXImagePanel1"); // NOI18N

        javax.swing.GroupLayout jXImagePanel1Layout = new javax.swing.GroupLayout(jXImagePanel1);
        jXImagePanel1.setLayout(jXImagePanel1Layout);
        jXImagePanel1Layout.setHorizontalGroup(
            jXImagePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jXImagePanel1Layout.setVerticalGroup(
            jXImagePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jXBusyLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jXBusyLabel.setText(resourceMap.getString("jXBusyLabel.text")); // NOI18N
        jXBusyLabel.setMaximumSize(new java.awt.Dimension(20, 20));
        jXBusyLabel.setMinimumSize(new java.awt.Dimension(20, 20));
        jXBusyLabel.setName("jXBusyLabel"); // NOI18N
        jXBusyLabel.setPreferredSize(new java.awt.Dimension(25, 25));

        jLabel1.setFont(jLabel1.getFont().deriveFont((jLabel1.getFont().getStyle() | java.awt.Font.ITALIC) | java.awt.Font.BOLD, jLabel1.getFont().getSize()+10));
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout jPnlMainLayout = new javax.swing.GroupLayout(jPnlMain);
        jPnlMain.setLayout(jPnlMainLayout);
        jPnlMainLayout.setHorizontalGroup(
            jPnlMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlMainLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPnlMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton1)
                    .addGroup(jPnlMainLayout.createSequentialGroup()
                        .addComponent(jXImagePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(59, 59, 59)
                        .addGroup(jPnlMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPnlMainLayout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jXBusyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(10, 10, 10))
        );
        jPnlMainLayout.setVerticalGroup(
            jPnlMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnlMainLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(jPnlMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jXImagePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPnlMainLayout.createSequentialGroup()
                        .addGroup(jPnlMainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPnlMainLayout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(34, 34, 34))
                            .addGroup(jPnlMainLayout.createSequentialGroup()
                                .addComponent(jXBusyLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                        .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addGap(11, 11, 11))
        );

        getContentPane().add(jPnlMain, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPnlMain;
    private javax.swing.JProgressBar jProgressBar1;
    private org.jdesktop.swingx.JXBusyLabel jXBusyLabel;
    private org.jdesktop.swingx.JXImagePanel jXImagePanel1;
    // End of variables declaration//GEN-END:variables

    /**
     * 
     * @param value
     */
    public void updateProgressBar(int value){
        this.jProgressBar1.setValue(value);        
    }    
 
    @Action
    public void cancel(){
        this.controller.cancel();
    }

    /**
     * @return the jXBusyLabel
     */
    public JXBusyLabel getjXBusyLabel() {
        return jXBusyLabel;
    }

    
}
